/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yazdankhah.tests;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.richfaces.model.TreeNode;
import org.richfaces.model.TreeNodeImpl;

/**
 *
 * @author ahmad
 */
@ManagedBean
@ViewScoped
public class TypifiedRichFacesTreeNodeBean {

  private TreeNode rootNode = null;


  public void initNodes() {
    rootNode = new TreeNodeImpl();
    TypifiedRichFacesTreeNode node = new TypifiedRichFacesTreeNode(
            "Desktop Type", SimpleTreeNodeTypes.NODE);
    node.addChild("1_1", new TypifiedRichFacesTreeNode("Compact", SimpleTreeNodeTypes.LEAF));
    node.addChild("1_2", new TypifiedRichFacesTreeNode("Everyday", SimpleTreeNodeTypes.LEAF));
    node.addChild("1_3", new TypifiedRichFacesTreeNode("Gaming", SimpleTreeNodeTypes.LEAF));
    node.addChild("1_4", new TypifiedRichFacesTreeNode("Premium", SimpleTreeNodeTypes.LEAF));
    rootNode.addChild("1", node);
//Other nodes initialization
  }


  public void setRootNode(TreeNode rootNode) {
    this.rootNode = rootNode;
  }


  public TreeNode getRootNode() {
    if (rootNode == null) {
      initNodes();
    }
    return rootNode;
  }

}
